package com.share.one.e_a_lifeCycle;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;


public class MyBeanPostProcessor implements BeanPostProcessor {

	@Override
	public Object postProcessBeforeInitialization(Object bean, String beanName)
			throws BeansException {
		System.out.println("后处理bean---前方法：" + beanName);
		return bean;
	}

	@Override
	public Object postProcessAfterInitialization(final Object bean, String beanName)
			throws BeansException {
		System.out.println("后处理bean---后方法：" + beanName);
		//		return Proxy.newProxyInstance(MyBeanPostProcessor.class.getClassLoader(), 
		//				bean.getClass().getInterfaces(), new InvocationHandler() {
		//
		//			@Override
		//			public Object invoke(Object proxy, Method method, Object[] args)
		//					throws Throwable {
		//				System.out.println("jdk动态代理前");
		//				Object obj = method.invoke(bean, args);
		//				System.out.println("jdk动态代理后");
		//				return obj;
		//			}
		//		});

		return bean;
	}

}
